<--- %%NOBANNER%% --> _repeat.sas
 BackForward

/*-------------------<---Start of Description-->---------------------\
| Concatenate characters n times;                                    |
|------------------------------------------------|
|--------------------------------------------------------------------|
|-----------<---Start of Files or Arguements Needed-->---------------|
| Arguments:                                                         |
|    char - the special characters;                                  |
|    n - the number of time you want to write the special characters;|
|------------<---End of Files or Arguements Needed-->----------------|
|--------------------------------------------------------------------|
|------------------<---Start of Files Created-->---------------------|
| Example: %put %_repeat('-',10);                                    |
| Usage: %_repeat(char,n);                                           |
\------------------<---Start of Files Created-->--------------------*/
%macro _repeat(char,n);
/*--------------------------------------------\
| Author:  Duo Zhou;                          |
| Created: 12-25-2001 1:09pm;                 |
| Purpose: Concatenate characters n times;    |
\--------------------------------------------*/
%local string char linesize n _ijklmn_;
%let char=%sysfunc(dequote(&char));
%let linesize = %SYSFUNC(GETOPTION(linesize));
%let string=;
%if (%quote(&n) eq) %then %let n=&linesize.;
%else %if %sysfunc(rxmatch(%sysfunc(rxparse(.|$a|$A|$w)),&n)) %then %do;
   %put ==> Alert! The character "&char" cannot be repeated "&n" times;
   %goto finish;
%end;
%if &n lt 0 %then %let n=&linesize.;
%else %if &n =0 %then;
%else %do; 
	%do _ijklmn_=1 %to &n;   
		%let string=&string.%quote(&char);
	%end;
%end; &string
%finish:
%mend _repeat;